package com.controller;

import com.pb.Person;
import com.sun.istack.internal.Nullable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by 石头哥哥 on 7/1/16.
 * PROJECT_NAME: common
 * PACKAGE_NAME: com.controller
 * COMMENT :
 */
@Controller
public class TestController {

    @RequestMapping(value = "/person")
    @ResponseBody
    public Person builder_person(@RequestBody Person person) {
        Person.Builder builder = Person.newBuilder();
        builder.setUsername("服务器响应!!!!");
        builder.setPwd("3456");
        return builder.build();

    }

    @RequestMapping(value = "/text/person")
    @ResponseBody
    public Person text_plain_builder(@Nullable @RequestParam(value = "username", required = false) String username) {
        Person.Builder builder = Person.newBuilder();
        builder.setUsername(username);
        builder.setPwd("text_plain_buildertext_plain_buildertext_plain_builder");
        return builder.build();
    }

}
